! function(window, document) {
    document.querySelector("#loginBtn").onclick = async function() {
        let resLogin = await ajax({
            type: "post",
            url: "/login",
            params: {
                name: document.querySelector("#name").value,
                password: document.querySelector("#password").value
            }
        })
        if (!resLogin.success) {
            location.href = "/register"
            alert(resLogin.data)
        } else {
            location.href = "/"
        }
    }
}(window, document)